﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YanZhiwei.DotNet4.Utilities.Common;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace YanZhiwei.DotNet4.Utilities.Common.Tests
{
    [TestClass()]
    public class ConvertHelperTests
    {
        [TestMethod()]
        public void CastToTest()
        {
            Assert.AreEqual(((object)null).CastTo<object>(), null);
            Assert.AreEqual("123".CastTo<int>(), 123);
            Assert.AreEqual(123.CastTo<string>(), "123");
            Assert.AreEqual(true.CastTo<string>(), "True");
            Assert.AreEqual("true".CastTo<bool>(), true);
            Assert.AreEqual("56D768A3-3D74-43B4-BD7B-2871D675CC4B".CastTo<Guid>(), new Guid("56D768A3-3D74-43B4-BD7B-2871D675CC4B"));
            Assert.AreEqual(1.CastTo<UriKind>(), UriKind.Absolute);
            Assert.AreEqual("RelativeOrAbsolute".CastTo<UriKind>(), UriKind.RelativeOrAbsolute);
            Assert.AreEqual("abc".CastTo<int>(123), 123);

            //  ExceptionAssert.IsException<FormatException>(() => "abc".CastTo<int>());
        }
    }
}
